When encoded data of a moving image is transmitted from an encoder to a decoder, an underflow and an overflow of a reception buffer that accumulates encoded data at a reception side needs to be prevented. To this end, the encoder uses a virtual buffer that is obtained by virtually modeling a reception buffer of the decoder to control an information amount to be generated by encoding a moving image so that the moving image is reproduced by the decoder with a substantially constant bit rate. The above-described virtual buffer is also referred to as a video buffering verifier (VBV) buffer.
For example, when a scene with an intense movement is switched to another scene, an information amount of encoded data generated at an interval until the scene switches shifts at a high level and an information amount of encoded data generated when the scene switches increases further. As a result, the reception buffer of the decoder may be depleted, in other words, a buffer underflow may be caused.
FIG. 16 illustrates an occurrence of a buffer underflow. Description will be made in the example of FIG. 16 by assuming a VBV buffer that is included in an ideal decoder and encoded data of a picture for which decoding is completed is removed from the VBV buffer immediately. The horizontal axis of the graph in FIG. 16 indicates time. Decoding Time Stamp (DTS) on the horizontal axis of the graph in FIG. 16 indicates a decoding time when encoded data is decoded by the VBV buffer, in other words, removal time when the encoded data is removed from the VBV buffer, and substantially the same time is assigned to encoded data for one picture. The vertical axis of the graph in FIG. 16 is an information amount of encoded data that occupies the VBV buffer, in other words, the buffer occupancy. The gradient of the graph in FIG. 16 indicates a bit rate of encoded data that is input to the VBV buffer.
As illustrated in FIG. 16, in intervals of DTS0, DTS1, and DTS2, pictures accumulated in the VBV buffer are removed after decoding. In the intervals of DTS0, DTS1, and DTS2, moving images with intense movement between frames are encoded. Accordingly, the buffer occupancy transitions with a tendency to be depleted. When the processing reaches the DTS3, a scene change of a video is caused and thereby an amount of encoded data that may not be input with an input bit rate to the VBV buffer is generated. As a result, buffering of encoded data of a picture to be decoded at DTS3 is not completed; thereby a buffer underflow occurs.
Japanese Laid-open Patent Publication No. 2001-169281 discusses a technology that skips encoding a macro block when an underflow of a VBV buffer is detected as a technology to prevent a buffer underflow. Skipping encoding a macro block as described above reduces an information amount of encoded data. The macro block here indicates data that is obtained by dividing moving image data before encoding into a certain size, for example, 16 pixels×16 pixels, or 8 pixels×8 pixels. The “skip” assumes a macro block to be encoded as a macro block of a picture that is already encoded.
When a scene of an image is switched from a state without movement, an information amount of encoded data generated in an interval until the scene change transitions with a low level. In contrast, an information amount of encoded data generated at the scene change is sharply increased. As a result, a state of an overflow of the reception buffer of the decoder, in other words, a buffer overflow may occur.
FIG. 17 illustrates occurrence of a buffer overflow. Description will be made in the example of FIG. 17, as in FIG. 16, by assuming a VBV buffer that is included in an ideal decoder and encoded data of a picture for which decoding is completed is removed from the VBV buffer immediately. Descriptions of the graph in FIG. 17 are substantially the same as those described by referring to FIG. 16.
As illustrated in FIG. 17, in intervals of DTS0, DTS1, and DTS2, pictures accumulated in the VBV buffer are removed after decoding respectively. In the intervals of DTS0, DTS1, and DTS2, moving images with no movement between frames are encoded. Thus, the buffer occupancy transitions with a tendency of an overflow. When the processing reaches the DTS3, a scene change of an image is caused and thereby an amount of encoded data that may not be accommodated in the VBV buffer is generated. Accordingly, all encoded data of a picture that needs to be decoded at DTS3 is not completely buffered and thereby the buffer overflow occurs.
Japanese Laid-open Patent Publication No. H09-139912 discusses a technology that inserts a stuffing bit that is treated as invalid data at decoding into encoded data when an overflow of a VBV buffer is detected as a technology to prevent the above-described buffer overflow. The stuffing reduces the buffer occupancy rate in the decoder.